/* typehints:start */
import { GameRoot } from "../../root";
/* typehints:end */

import { makeDiv } from "../../../core/utils/utils";
import { BaseHUDPart } from "../base_hud_part";

export class HUDTaskPage extends BaseHUDPart{
  constructor(root){
    /** @type {GameRoot} */
    super(root);
  }

  createElements(parent){
    this.element = makeDiv(parent, 'task_page', ['hud_page', 'page', 'task_page', 'remove'], `
    `);
  }
  
  initialize(){
    this.drawTask();
  }

  drawTask(){
    let tasks = this.root.task.getAllTask();

    this.element.innerHTML = '';

    if(tasks.length){
      tasks.map(task => {
        let taskType = task.getTaskType();
  
        let dom = makeDiv(this.element, '', ['item'], `
          <h3 class="title">${task.getTitle()} <span class="tag ${taskType.color}">${taskType.title}</span></h3>
          <p class="desc">${task.getDesc()}</p>
          <p class="tip">${task.getTip()}</p>
        `)
      })
    } else {
      this.element.innerHTML = '<div class="no-task">未接受到任何任务</div>'
    }
  }
}